﻿function AzureOnlineTableSettingsView(context) {

    var self = this;
    
    var dispatcher = $({});

    var screen = ko.observable('columns');
    
    var tableColumns = context.tables.tableColumns;
    var tableMarkers = new AzureOnlineTableMarkersView(context);
    
    function initFromCurrent() {
        
    }
    
    function addOnSuccess(handler) {
        dispatcher.bind('success', handler);
    };
    
    function goToColumns() {
        screen('columns');
    }
    
    function goToMarkers() {
        screen('markers');
    }
    
    function apply() {
        tableColumns.save();
        tableMarkers.save();
        dispatcher.trigger('success');
    }
    
    function reset() {
        switch(screen()) {
            case 'columns':
                tableColumns.reset();
                break;
            case 'markers':
                tableMarkers.reset();
                break;
        }
    }

    self.initFromCurrent = initFromCurrent;
    self.screen = screen;
    self.goToColumns = goToColumns;
    self.goToMarkers = goToMarkers;
    self.tableColumns = tableColumns;
    self.tableMarkers = tableMarkers;
    self.apply = apply;
    self.reset = reset;
    self.addOnSuccess = addOnSuccess;
}
